/* ========================================================================== */
/*   Log.h                           			                              */
/*   (c) 2012 Team 7 Hogeschool Utrecht ICT TI                                */
/*		Lars Stolwijk, Gerben Boot, Guido van Hienen, Marcel Boelen			  */
/*                                                                            */
/*   Logs the Gametime, Health and WeaponID when the player gets hit. Resets  */
/*		and gets entire log when requested.								      */
/* ========================================================================== */

#ifndef __Log
#define __Log

#include "pRTOS.h"
#include "LogLine.h"
#include "ReadLogHandler.h"
#include "LogFile.h"

class ReadLogHandler;

//***************************************************************************
//
// class Log
//
//! Logs the Gametime, Health and WeaponID when the player gets hit. Resets and gets entire log when requested.	
//
//***************************************************************************

class Log : public RTOS::task {
	public:	
		//! Constructor
		Log(int prio, ReadLogHandler * readLogHandler) : RTOS::task(prio, "LogTask"), theReadLogHandler(readLogHandler), ClearLogFlag(this, "ClearLogFlag"), GetLogFlag(this, "GetLogFlag"), LogChannel(this, "LogChannel"){}
		
		//! Sets the ClearLogFlag
		void ClearLog();
		
		//! Sets the GetLogFlag
		void GetLog();
		
		//! Writes a new LogLine into the LogChannel
		void WriteLog(char p, char w, char h, short t);
		
	private:
		ReadLogHandler * theReadLogHandler;
	
		RTOS::flag ClearLogFlag, GetLogFlag;
		RTOS::channel< LogLine, 50 > LogChannel;
	
		LogLine log[50];
		char logCount;
		
		//! The main method
		void main();
};

#endif
